﻿package com.wandian.view.components.ui
{
	import com.greensock.TweenLite;
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.InRoomPlayerDataProxy;
	import com.wandian.model.UserInfoProxy;
	import com.wandian.model.vo.*;
	import com.wandian.util.CLZButton;
	import com.wandian.util.CLZButtonFour;
	import com.wandian.util.CLZSlideTwo;
	import com.wandian.util.CLZTabBar;
	import com.wandian.util.GlowFilterManage;
	import com.wandian.util.TextControl;

	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	/**
	 * 牌型分类帮助
	 * list1-list10,10种牌型
	 * @author long
	 * @Create  2012-10-23
	 * @QQ 108232706
	 * @version 1.0
	 */
	public class CardTypeTipPanel extends Object
	{
		private var _mcCardSort:Sprite;
		private var _arrMcList:Array;
		private const INITX:Number=960.6;
		private const INITY:Number=66.55;
		private const SHOWX:Number=722.6;
		private const SHOWY:Number=66.55;
		private var facade:ApplicationFacade;

		public function CardTypeTipPanel(mcardSort:Sprite)
		{
			this.facade=ApplicationFacade.getInstance();
			this._mcCardSort=mcardSort;
			this._mcCardSort.visible=false;
			Texas.I._mcTipView.addChild(this._mcCardSort);
			this._mcCardSort.x=this.INITX;
			this._mcCardSort.y=this.INITY;
			this._arrMcList=[this._mcCardSort["list1"], this._mcCardSort["list2"], this._mcCardSort["list3"], this._mcCardSort["list4"], this._mcCardSort["list5"], this._mcCardSort["list6"], this._mcCardSort["list7"], this._mcCardSort["list8"], this._mcCardSort["list9"], this._mcCardSort["list10"]];
			this._mcCardSort.addEventListener(MouseEvent.ROLL_OUT, this.outMouseHandler);
			this.init();
			return;
		}

		private function outMouseHandler(event:MouseEvent):void
		{
			this.hide();
			return;
		}

		public function get panel():Sprite
		{
			return this._mcCardSort;
		}

		public function show():void
		{
			this._mcCardSort.visible=true;
			TweenLite.to(this._mcCardSort, 0.5, {x: this.SHOWX, y: this.SHOWY, onComplete: this.onShowStop});
			return;
		}

		public function hide():void
		{
			TweenLite.to(this._mcCardSort, 0.5, {x: this.INITX, y: this.INITY, onComplete: this.onHideStop});
			return;
		}

		private function onHideStop():void
		{
			this._mcCardSort.visible=false;
			this.facade.sendNotification(CLZNoticeName.HIDE_CARD_RANK_TIP_COMPLETE);
			return;
		}

		private function onShowStop():void
		{
			return;
		}

		private function init():void
		{
			var cardSortVo:CardSortVo=null;
			var mcList:Sprite=null;
			var cards:Array=null;
			var cardMgr:CardManage=null;
			var cardIndex:int=0;
			var _xml:XML=<CardMaxToMin>
					<item type='0' cards='Jd-7s-5h-2d-6s' probability='1/2'/>
					<item type='1' cards='8c-8h-7s-Jd-4h' probability='1/3'/>
					<item type='2' cards='Ts-Th-2d-2c-7s' probability='1/21'/>
					<item type='3' cards='8d-8c-8h-Js-Ts' probability='1/47'/>
					<item type='4' cards='4d-5c-6h-7s-8s' probability='1/254'/>
					<item type='5' cards='3h-7h-Th-5h-Kh' probability='1/508'/>
					<item type='6' cards='8d-8c-8h-Jc-Jh' probability='1/694'/>
					<item type='7' cards='6d-6c-6h-6s-4d' probability='1/4165'/>
					<item type='8' cards='Ks-Qs-Js-Ts-9s' probability='1/72193'/>
					<item type='9' cards='As-Ks-Qs-Js-Ts' probability='1/649740'/>
				</CardMaxToMin>;
			var items:XMLList=_xml.item as XMLList;
			var arrCard:Array=[];
			var count:uint=0;
			while (count < items.length())
			{
				cardSortVo=new CardSortVo();
				cardSortVo.type=items[count].@type;
				cardSortVo.cards=items[count].@cards;
				cardSortVo.probability=items[count].@probability;
				arrCard.push(cardSortVo);
				count=count + 1;
			}
			arrCard=GameData.sortMaxToMinArray(arrCard, "type");
			var arrTip:*=GameData.tip["cardType"].split("|");
			count=0;
			while (count < arrCard.length)
			{
				cardSortVo=arrCard[count] as CardSortVo;
				mcList=this._arrMcList[count] as Sprite;
				mcList["txt"].htmlText="<font color=\'#ffff00\'>" + arrTip[cardSortVo.type] + "</font><br/>" + GameData.tip["PROBABILITY"] + ":" + cardSortVo.probability;
				cards=cardSortVo.cards.split("-");
				cardIndex=0;
				while (cardIndex < 5)
				{
					cardMgr=new CardManage(mcList["card" + (cardIndex + 1)], false);
					cardMgr.showCard(cards[cardIndex], false);
					cardMgr.cacheAsBitmap=true;
					cardIndex=cardIndex + 1;
				}
				count=count + 1;
			}
			return;
		}

	}
}

class CardSortVo extends Object
{
	public var type:int;
	public var cards:String;
	public var probability:String;

	function CardSortVo()
	{
		return;
	}

}

